<html>
<head><meta charset="utf-8"><title>Getting gen_lsp_server working · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Getting.20gen_lsp_server.20working.html">Getting gen_lsp_server working</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="166215054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Getting%20gen_lsp_server%20working/near/166215054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> D. Moonfire <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Getting.20gen_lsp_server.20working.html#166215054">(May 21 2019 at 21:35)</a>:</h4>
<p>I'm trying to figure out why I can't get <code>gen_lsp_server</code> working and it appears to be hanging on the threaded stdin/stdout logic in <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/gen_lsp_server/src/stdio.rs" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/gen_lsp_server/src/stdio.rs">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/gen_lsp_server/src/stdio.rs</a>. I think it is because we are doing something on both the stdin and the stdout at the same time.</p>
<p>I managed to get it down to a minimal case using code stolen from that crate (<a href="https://github.com/dmoonfire/minimal-rust-lsp/blob/master/src/main.rs" target="_blank" title="https://github.com/dmoonfire/minimal-rust-lsp/blob/master/src/main.rs">https://github.com/dmoonfire/minimal-rust-lsp/blob/master/src/main.rs</a>) but I'm not sure how to get around the blocking error. If I comment lines 37-42, it works fine but that obviously isn't what it was indented.</p>
<p>I found a few other examples of it, but the only one that I understood uses <code>futures</code> which doesn't appear to be used by <code>gen_lsp_server</code>. Since I have to work with private structs in that crate, I figured I would have to match the libraries used in that example so futures doesn't have a future unless something changes.</p>
<p>Any chance someone can point me to a way of figuring this out?</p>



<a name="166243803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Getting%20gen_lsp_server%20working/near/166243803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Getting.20gen_lsp_server.20working.html#166243803">(May 22 2019 at 07:31)</a>:</h4>
<p>WHere exactly does it hang?</p>



<a name="166243815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Getting%20gen_lsp_server%20working/near/166243815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Getting.20gen_lsp_server.20working.html#166243815">(May 22 2019 at 07:31)</a>:</h4>
<p>If that's the join call, than the issue might be an unclosed stdout on the other side</p>



<a name="166243817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Getting%20gen_lsp_server%20working/near/166243817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Getting.20gen_lsp_server.20working.html#166243817">(May 22 2019 at 07:31)</a>:</h4>
<p><a href="https://github.com/dmoonfire/minimal-rust-lsp/blob/9a971993f46204dbc895638efd819e3486aa8303/src/main.rs#L25" target="_blank" title="https://github.com/dmoonfire/minimal-rust-lsp/blob/9a971993f46204dbc895638efd819e3486aa8303/src/main.rs#L25">https://github.com/dmoonfire/minimal-rust-lsp/blob/9a971993f46204dbc895638efd819e3486aa8303/src/main.rs#L25</a></p>



<a name="166243876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Getting%20gen_lsp_server%20working/near/166243876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Getting.20gen_lsp_server.20working.html#166243876">(May 22 2019 at 07:32)</a>:</h4>
<p>The way I would debug this is to add logging to the lowest possible level, stdio transport, to figure out which message can't get through</p>



<a name="166268507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Getting%20gen_lsp_server%20working/near/166268507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> D. Moonfire <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Getting.20gen_lsp_server.20working.html#166268507">(May 22 2019 at 13:46)</a>:</h4>
<p>It was on the <code>let req = match receiver.recv() {</code> call. However I decided to try something and switched logging libraries (to handle the <code>trace!</code>) and made sure all the logging output was going to stderr. Apparently the logging library (simple_logger) was conflicting with the <code>stdout.lock()</code>, which makes sense in hindsight. Thank you.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>